﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WinFrom2
{
    public  class Dbhelper
    {
        public  static readonly string conString = "server=.;database=Blogs;uid=sa;pwd=030824";
        

        public static DataTable GetDataTable(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlDataAdapter dataAdapter = new SqlDataAdapter(sql, connection);
            DataTable table = new DataTable();
            connection.Open();
            dataAdapter.Fill(table);
            return table;
        }
        public static int AddOrEdiOrdeletetSave(string sql)
        {
            SqlConnection connection = new SqlConnection(conString);
            SqlCommand command = new SqlCommand(sql, connection);
            connection.Open();
            return command.ExecuteNonQuery();
        }
    }
}
